/**
 * 
 */
package com.guchenbo.example.classloader;

import java.lang.reflect.Method;

/**
 * @author Cre.Gu
 *
 */
public class Test3 {
	static {
		System.out.println("静态初始化块执行了！");
	}
	
	public static void main(String[] args) {
		String classDataRootPath = "C:\\Users\\CreGu\\git\\cre-parent\\cre-sample\\target\\test-classes";
		FileSystemClassLoader fscl1 = new FileSystemClassLoader(classDataRootPath);
		FileSystemClassLoader fscl2 = new FileSystemClassLoader(classDataRootPath);
		String className = "cre.sample.test.classloader.Sample";
		try {
			Class<?> class1 = fscl1.loadClass(className);
			Object obj1 = class1.newInstance();
			Class<?> class2 = fscl2.loadClass(className);
			Object obj2 = class2.newInstance();
			Method setSampleMethod = class1.getMethod("setSample", java.lang.Object.class);
			setSampleMethod.invoke(obj1, obj2);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
